package com.cy.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.Session;

public interface BaseDAO<T> {

	/**
	 * Generic method used to get all objects of a particular type. This is the
	 * same as lookup up all rows in a table.
	 * 
	 * @param clazz
	 *            the type of objects (a.k.a. while table) to get data from
	 * @return List of populated objects
	 */
	public List<T> getObjects(Class<T> clazz);

	public List<T> getObjectsByPageSize(String queryString, String[] params, Object[] values, Integer startIndex, Integer pageSize);

	public List<T> getObjectsByParam(String queryString, String[] params, Object[] values);

	/**
	 * Generic method to get an object based on class and identifier. An
	 * ObjectRetrievalFailureException Runtime Exception is thrown if nothing is
	 * found.
	 * 
	 * @param clazz
	 *            model class to lookup
	 * @param id
	 *            the identifier (primary key) of the class
	 * @return a populated object
	 * @see org.springframework.orm.ObjectRetrievalFailureException
	 */
	public T getObject(Class<T> clazz, Serializable id);

	public T getObject(Class<T> clazz, Serializable id, boolean isLazyDetail);

	public int getCount(String queryString, String[] params, Object[] values);
	
	public int getCountBySQLQuery(String queryString, String[] params, Object[] values);
	/**
	 * Generic method to save an object - handles both update and insert.
	 * 
	 * @param o
	 *            the object to save
	 */
	public void saveObject(T o);

	public void saveObjects(T[] ts);

	public void saveObjects(Collection<T> ts);

	/**
	 * Generic method to delete an object based on class and id
	 * 
	 * @param clazz
	 *            model class to lookup
	 * @param id
	 *            the identifier (primary key) of the class
	 */
	public void removeObject(Class<T> clazz, Serializable id);

	public void removeObjects(Class<T> clazz, Serializable[] ids);

	public void removeObjects(Class<T> clazz, Collection<Serializable> ids);
	
	
	public Session getCurrentSession();

}
